package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysAClientList;
import com.ruoyi.system.service.ISysAClientListService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户测试Controller
 * 
 * @author ruoyi
 * @date 2021-11-08
 */
@Controller
@RequestMapping("/system/clientlist")
public class SysAClientListController extends BaseController
{
    private String prefix = "system/clientlist";

    @Autowired
    private ISysAClientListService sysAClientListService;

    @RequiresPermissions("system:clientlist:view")
    @GetMapping()
    public String clientlist()
    {
        return prefix + "/clientlist";
    }

    /**
     * 查询客户测试列表
     */
    @RequiresPermissions("system:clientlist:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysAClientList sysAClientList)
    {
        startPage();
        List<SysAClientList> list = sysAClientListService.selectSysAClientListList(sysAClientList);
        return getDataTable(list);
    }

    /**
     * 导出客户测试列表
     */
    @RequiresPermissions("system:clientlist:export")
    @Log(title = "客户测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysAClientList sysAClientList)
    {
        List<SysAClientList> list = sysAClientListService.selectSysAClientListList(sysAClientList);
        ExcelUtil<SysAClientList> util = new ExcelUtil<SysAClientList>(SysAClientList.class);
        return util.exportExcel(list, "客户测试数据");
    }

    /**
     * 新增客户测试
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存客户测试
     */
    @RequiresPermissions("system:clientlist:add")
    @Log(title = "客户测试", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysAClientList sysAClientList)
    {
        return toAjax(sysAClientListService.insertSysAClientList(sysAClientList));
    }

    /**
     * 修改客户测试
     */
    @GetMapping("/edit/{clientId}")
    public String edit(@PathVariable("clientId") String clientId, ModelMap mmap)
    {
        SysAClientList sysAClientList = sysAClientListService.selectSysAClientListByClientId(clientId);
        mmap.put("sysAClientList", sysAClientList);
        return prefix + "/edit";
    }

    /**
     * 修改保存客户测试
     */
    @RequiresPermissions("system:clientlist:edit")
    @Log(title = "客户测试", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysAClientList sysAClientList)
    {
        return toAjax(sysAClientListService.updateSysAClientList(sysAClientList));
    }

    /**
     * 删除客户测试
     */
    @RequiresPermissions("system:clientlist:remove")
    @Log(title = "客户测试", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysAClientListService.deleteSysAClientListByClientIds(ids));
    }
}
